package com.twu.biblioteca;

public class ReserveController {

    private BookManager bookManager;

    private UserInterface userInterface;

    public void setBookManager(BookManager bookManager) {
        this.bookManager = bookManager;
    }

    public BookManager getBookManager() {
        return bookManager;
    }

    public void setUserInterface(UserInterface userInterface) {
        this.userInterface = userInterface;
    }

    public void enter() {
        userInterface.prompt("Please insert book title:");
        String book = userInterface.nextInput();
        reserve(book);
    }

    /* default */ void reserve(String book) {
        boolean reservationResult = bookManager.reserveBook(book);
        if (reservationResult == true) {
            userInterface.showReservationSucceededMessage();
        } else {
            userInterface.showReservationFailedMessage();
        }
    }

}
